package com.senseuni.da.ui

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.senseuni.da.R
import com.senseuni.da.databinding.FragmentBackupRestoreBinding
import com.senseuni.da.ui.dialog.SimpleListDialog
import com.senseuni.da.ui.dialog.SimpleListItem


class BackupRestoreFragment : Fragment() {

    companion object {
        fun newInstance() = BackupRestoreFragment()
    }

    private lateinit var binding: FragmentBackupRestoreBinding

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        binding = FragmentBackupRestoreBinding.inflate(inflater, container, false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding.sivReset.setOnClickListener {
            val item1 = SimpleListItem()
            item1.key = "reset"
            item1.value = getString(R.string.clear_data)
            val item2 = SimpleListItem()
            item2.key = "restore"
            item2.value = getString(R.string.restore_factory)
            val list = listOf(item1, item2)
            SimpleListDialog(requireContext(), getString(R.string.reset_frame), list)
                .setOnResultListener { dialog, result ->

                }
                .create().show()
        }
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
    }


}